package com.zb.enums;

import org.apache.commons.lang.StringUtils;

/**
 * @author lyx
 * @create 2021/9/8 10:56
 * @description:
 */
public enum RoleEnum {
    /**普通用户*/
    USER("user","普通用户"),
    /**管理员*/
    ADMIN("admin","管理员"),
    /**根用户*/
    ROOT("root","根用户");


    private final String name;
    /**
     * 用户角色名称中文
     */
    private final String nameZh;

    RoleEnum(String name, String nameZh) {
        this.name = name;
        this.nameZh = nameZh;
    }

    public static RoleEnum getByName(String name){
        if(StringUtils.isBlank(name)){
            return null;
        }
        for(RoleEnum roleEnum:RoleEnum.values()){
            if(roleEnum.name.equals(name)){
                return roleEnum;
            }
        }
        return null;
    }


    public String getName() {
        return name;
    }

    public String getNameZh() {
        return nameZh;
    }
}
